package com.simple.ds.service.impl;

import cn.hutool.crypto.digest.DigestUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.primitives.Longs;
import com.simple.common.entity.po.MerchantEntity;
import com.simple.ds.mapper.MerchantMapper;
import com.simple.ds.service.MerchantService;
import org.springframework.stereotype.Service;

/**
 * @author yasud
 * @date 2021年09月17日 15:30
 * @description
 */
@Service
public class MerchantServiceIml extends ServiceImpl<MerchantMapper, MerchantEntity> implements MerchantService {


    @Override
    public MerchantEntity findMerchantByExpId(Long expId) {
        for (MerchantEntity merchantEntity : list()) {
            String code = merchantEntity.getMerchantCode();
            if (Longs.fromByteArray(DigestUtil.sha256(code + "_example")) == expId) {
                return merchantEntity;
            }
        }
        return null;
    }
}
